package com.fuhe.chen.vendingmachine.dao;

import com.fuhe.chen.vendingmachine.pojo.RelationshipItemMachine;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface RelationshipItemMachineDao {
    /**
     * 新增在售商品
     * @param relationship
     */
    void addRelationship(RelationshipItemMachine relationship);

    /**
     * 根据商品id删除在售商品
     * @param itemId
     */
    void deleteRelationship(@Param("itemId") Integer itemId);

    /**
     * 按条件查询
     * @param machineId 机器主键
     * @param itemId 商品主键
     * @return
     */
    List<RelationshipItemMachine> findByCondition(@Param("machineId") Integer machineId, @Param("itemId") Integer itemId);

    /**
     * 查找单个在售商品信息
     * @param containerNumber
     * @param machineId
     * @return
     */
    RelationshipItemMachine findOne(@Param("containerNumber") String containerNumber,@Param("machineId") Integer machineId);

    /**
     * 查找单个在售商品信息
     * @return
     */
    RelationshipItemMachine findOneById(@Param("id") Integer id);


    /**
     * 查询商品库存
     */
    Integer findStock(RelationshipItemMachine commodity);
}
